//
//  ZJAdressCell.m
//  ZiJinLian
//
//  Created by lzy on 2017/3/19.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "ZJAddressCell.h"

@implementation ZJAddressCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.nameLab=[ZJUITools getLab_S14_C3];
        [self addSubview:self.nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(10);
            make.top.equalTo(self.mas_top).offset(10);
            make.width.mas_equalTo(MainW/2-10);
            
        }];
        self.phoneLab=[ZJUITools getLab_S14_C3];
        [self addSubview:self.phoneLab];
        _phoneLab.textAlignment=NSTextAlignmentRight;
        [_phoneLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).offset(-10);
            make.top.equalTo(self.mas_top).offset(10);
            make.width.mas_equalTo(MainW/2-10);
        }];
        
        self.addressLab=[ZJUITools getLab_S14_C3];
        self.addressLab.numberOfLines=1;
        [self addSubview:self.addressLab];
        [_addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(10);
            make.top.equalTo(_nameLab.mas_bottom).offset(10);
            make.right.equalTo(self.mas_right).offset(-10);
        }];
        
        self.defaultLab=[ZJUITools getLab_S14_C3];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setUpCellViewAndModel:(ZJAdressModel *)model
{
    self.nameLab.text=[NSString stringWithFormat:@"收货人:%@",model.consigneeName];
    self.phoneLab.text=[NSString stringWithFormat:@"手机号:%@",model.consigneePhone];;
    NSString* str=[NSString stringWithFormat:@"%@%@",[model.area stringByReplacingOccurrencesOfString:@" " withString:@""],model.detail];
    if (model.isDefault==1) {//默认
        NSMutableAttributedString *str2 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@",@"[默认地址]",str]];
        [str2 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,6)];
        self.addressLab.attributedText=str2;
    }else{
        self.addressLab.text=[NSString stringWithFormat:@"收货地址:%@",str];
    }
}


@end
